//
//  ClubMessageTableViewCell.swift
//  77Club
//
//  Created by Apple on 2024/9/3.
//

import UIKit

class ClubMessageTableViewCell: UITableViewCell {

    let backView = c_make_ex(UIView.self)
        .bgColor(.white).corner(12.0.Scale).end()
    private let bellImageView = c_make_ex(UIImageView.self)
        .image("HomeMsg_bell").mode(.scaleAspectFill).end()
    private let titleLabel = c_make_ex(UILabel.self)
        .color("#C4C4C4").font(13.font_regular).end()
    private let timeLabel = c_make_ex(UILabel.self)
        .color("#C4C4C4").font(13.font_regular)
        .alignment(.right).end()
    private let contentLabel = c_make_ex(UILabel.self)
        .color("#565656").font(15.font_regular).end()
    
    var model: ClubMessageModel?{
        didSet{
            guard let md = model else { return }
            
            titleLabel.text = md.type
            timeLabel.text = md.time
            contentLabel.text = md.name
            if md.read == "0" {
                contentLabel.textColor = "#565656".toColor
            }else{
                contentLabel.textColor = "#C4C4C4".toColor
            }
        }
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        contentView.subviews{
            backView.subviews{
                bellImageView
                titleLabel
                timeLabel
                contentLabel
            }
        }
                
        backView.bottom(0).leading(12.0.Scale).trailing(12.0.Scale).top(12.0.Scale)
        bellImageView.leading(12.0.Scale).top(12.0.Scale).size(16.0.Scale)
        timeLabel.trailing(16.0.Scale).width(<=140)
        timeLabel.CenterY == bellImageView.CenterY
        titleLabel.leading(35.0.Scale)
        titleLabel.CenterY == bellImageView.CenterY
        titleLabel.Trailing == timeLabel.Leading
        contentLabel.leading(30.0.Scale).trailing(20.0.Scale)
        contentLabel.Top == bellImageView.Bottom + 10.0.Scale
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
